<?php include (dirname(__FILE__)."/../include/header.php"); ?>
<?php if(!isset($_SESSION['_user'])){header("location:../user_login.php");}?>
<?php
	$sql="SELECT zy_shop.* FROM zy_shop,zy_favoshop WHERE zy_shop.shop_id = zy_favoshop.shop_id AND zy_favoshop.user_id = '".$_SESSION['_user']['user_id']."'";
	$rs=mysql_query($sql);
	$total_favo=mysql_num_rows($rs);
	
?>
<div class="container">
<ul class="breadcrumb">
 <li><a href="<?php echo SITE_ROOT; ?>">返回首页</a><span class="divider">/</span></li>
 <li><a href="<?php echo SITE_ROOT."/user/favo_store.php"; ?>">我收藏的餐厅</a></li>
</ul>
<div class="row">
  <div class="span12 wash-paper profile">
    <div class="row">
      <div class="span3">
        <?php include (dirname(__FILE__)."/../include/user/left.php"); ?>
        <div class="span9">
          <div class="main-content">
            <div class="content-header">
              <h3>我收藏的餐厅- 共<span id="total-favo-shop"><?php echo $total_favo;?></span>家</h3>
            </div>
            <div class="content-inner">
             <table class="favor_table table table-striped">
                <thead>
                  <tr>
                  
                    <th>店标</th>
                      <th>餐厅</th>
                    <th>地址</th>
                    <th>电话</th>
                    <th>删除</th>
                  </tr>
                </thead>
                <tbody>
                    <?php while($shop=mysql_fetch_array($rs)){?>
                  <tr class="favor_food" >
                    <td><div class="logo"> <a href="<?php echo SITE_ROOT;?>/index_shop.php?shop_id=<?php echo $shop['shop_id'];?>" target="_blank"><img width="42" height="42" class="restaurant-logo" alt="" 
							<?php if($shop['logo']==""){ ?>
					   src="<?php echo SITE_ROOT;?>/userfiles/shoplogo/logo.jpg"
					   <?php }else{?>
					   src="<?php echo SITE_ROOT;?><?php echo $shop['logo'];?>" <?php }?>/></a> </div>
					   </td>
					   <td><a href="<?php echo SITE_ROOT;?>/index_shop.php?shop_id=<?php echo $shop['shop_id'];?>" target="_blank"><?php echo $shop['shop_name'];?></a></td>
                    <td><?php echo $shop['shop_address'];?></td>
                    <td><?php echo $shop['shop_phone'];?></td>
                    <td><span class="admin_del" shopId="<?php echo $shop['shop_id'];?>"> <a href="javascript:;">删除</a> </span> </td>
                  </tr>
                  <?php } ?>
                </tbody>
              </table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <a id="back-to-top" href="javascript:void(0);">
  <div class="backtotop"></div>
  </a> </div>
<?php include (dirname(__FILE__)."/../include/footer.php"); ?>
<script type="text/javascript">
$(document).ready(function(){
	$(".admin_del").click(function(){
		var row=$(this).parent().parent();
		$.ajax({
            type: "post",
            url: "../include/zy_function.php",
			data:{method:"unFavoShop",shop_id:$(this).attr("shopId")},
            dataType: "json",
            success: function(){
            	row.remove();
            	$("#total-favo-shop").html($("#total-favo-shop").html()-1);
            }
         });
	});
});
</script>